package com.lhkj.ct.base.json.databind;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.lhkj.ct.base.enums.IBaseEnum;

import java.io.IOException;

/**
 * 用于BaseEum的子类解析成json格式，一般在api中注入此解析器
 * @author  Binz
 * 2019-05-27 11:29:02
 */
public class BaseEnumWritingByLabelSerializer extends JsonSerializer<IBaseEnum<?, ?>>{

    @Override
    public void serialize(IBaseEnum value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeObject( value.getLabel());
    }

}
